home *** CD-ROM | disk | FTP | other *** search
- /*
- * Modified and renamed src2ras, 1988 by Phill Everson for inclusion into ALV
- * toolkit.
- *
- * dumpregion - dump a region of a sun screen in rasterfile format. Copyright
- * Richard Tobin 1987. You may freely copy, modify and distribute this
- * program in source form provided this comment remains intact.
- *
- * Richard Tobin, JANET: R.Tobin@uk.ac.ed AI
- * Applications Institute, ARPA: R.Tobin%uk.ac.ed@nss.cs.ucl.ac.uk
- * Edinburgh University. UUCP: ...!ukc!ed.ac.uk!R.Tobin
- */
-
- #include "defs.h"
- #include <sys/file.h>
- #include <suntool/fullscreen.h>
-
- har *progname;
-
- hort nwdata[] = {
- #include "../images/cursors/stretchNW.cursor"
- };
- pr_static(nwpixrect, 16, 16, 1, nwdata);
-
- hort sedata[] = {
- #include "../images/cursors/stretchSE.cursor"
- };
- pr_static(sepixrect, 16, 16, 1, sedata);
-
- ect rect = {0, 0, 0, 0};
-
- olormap_t *colormap = NULL;
-
- #ifdef STANDALONE
- ain(argc, argv, envp)
- #else
- cr2ras_main(argc, argv, envp)
- #endif
- int argc;
- char **argv;
- char **envp;
- {
- int wfd;
- struct fullscreen *fs;
- Event event;
- Pixwin *pw;
- int left, right, top, bottom, temp;
- Window win;
- double w;
-
- progname = strsave(argv[0]);
- parse_profile(&argc, argv, envp);
-
- while ((gc = getopt(argc, argv, " ")) != EOF)
- switch (gc) {
- case '?':
- errflag++;
- break;
- }
-
- if (errflag)
- error((char *) 0, "Usage: %s: [outfile]\n", progname);
-
- for (stream = 0; optind < argc; stream++, optind++)
- if (stream ==0 && strcmp(argv[optind], "-") != 0)
- if (freopen(argv[optind],"w" ,stdout) == NULL)
- error("%s %s", PR_IO_ERR_INFILE, argv[optind]);
-
- win = window_create(0, FRAME,
- FRAME_OPEN_RECT, &rect,
- WIN_CONSUME_PICK_EVENTS,
- LOC_MOVE, WIN_MOUSE_BUTTONS, 0,
- 0);
-
- wfd = (int) window_get(win, WIN_FD);
- fs = fullscreen_init(wfd);
- pw = fs->fs_pixwin;
-
- window_set(win,
- WIN_CURSOR, cursor_create(CURSOR_IMAGE, &nwpixrect,
- CURSOR_XHOT, 0, CURSOR_YHOT, 0,
- 0),
- 0);
-
- while (window_read_event(win, &event) == -1 ||
- !event_is_down(&event) ||
- !event_is_button(&event));
-
- right = left = event_x(&event);
- bottom = top = event_y(&event);
-
- window_set(win,
- WIN_CURSOR, cursor_create(CURSOR_IMAGE, &sepixrect,
- CURSOR_XHOT, 15, CURSOR_YHOT, 15,
- 0),
- 0);
-
- drawbox(pw, left, top, right, bottom);
-
- while (window_read_event(win, &event) == -1 ||
- !event_is_up(&event) ||
- !event_is_button(&event)) {
- drawbox(pw, left, top, right, bottom);
- right = event_x(&event);
- bottom = event_y(&event);
- drawbox(pw, left, top, right, bottom);
- }
-
- drawbox(pw, left, top, right, bottom);
- fullscreen_destroy(fs);
-
- window_set(win, FRAME_NO_CONFIRM, TRUE, 0);
- window_destroy(win);
-
- if (right < left) {
- temp = right;
- right = left;
- left = temp;
- }
- if (bottom < top) {
- temp = bottom;
- bottom = top;
- top = temp;
- }
- dumpregion(left, top, right, bottom);
-
- return 0;
- }
-
- rawbox(pw, left, top, right, bottom)
- Pixwin *pw;
- int left, top, right, bottom;
- {
- fullscreen_pw_vector(pw, left, top, right, top, PIX_NOT(PIX_DST), 0);
- fullscreen_pw_vector(pw, right, top, right, bottom, PIX_NOT(PIX_DST), 0);
- fullscreen_pw_vector(pw, right, bottom, left, bottom, PIX_NOT(PIX_DST), 0);
- fullscreen_pw_vector(pw, left, bottom, left, top, PIX_NOT(PIX_DST), 0);
- }
-
- umpregion(left, top, right, bottom)
- int left, top, right, bottom;
- {
- Pixrect *pr, *pr2, *pr3;
- int width, height;
-
-
- pr = pr_open("/dev/fb");
- if (pr == 0)
- error("Can't open /dev/fb");
-
- width = (((right - left + 1) / 8) * 8);
- height = (((bottom - top + 1) / 4) * 4);
- pr2 = pr_region(pr, left, top, width, height);
- pr3 = pr_region(pr2, 0, 0, width, height);
-
- if (pr_dump(pr3, stdout, colormap, RT_STANDARD, 1) != 0) {
- perror("pr_dump");
- exit(1);
- }
- }
-